package com.example.web_project_xianyu.mappers;

import com.example.web_project_xianyu.entity.Comment;
import com.example.web_project_xianyu.entity.star_like_entity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface starMapper {
    @Select("select * from star_table where user_id = #{user_id} and product_id=#{product_id}")
    star_like_entity get_star_by_user_and_product_id(@Param("user_id")int user_id, @Param("product_id")int product_id);

    @Insert("insert into star_table(user_id, product_id) values(#{user_id}, #{product_id})")
    void add_star(@Param("user_id")int user_id,@Param("product_id")int product_id);

    @Delete("delete from star_table where user_id = #{user_id} and product_id=#{product_id}")
    void delete_star(@Param("user_id")int user_id,@Param("product_id")int product_id);

    @Select("select * from star_table where user_id = #{user_id}")
    List<star_like_entity> get_star_by_userid(int user_id);

    @Delete("delete from star_table where product_id=#{product_id}")
    void delete_product(int product_id);
}
